<template>
  <div>
    <div>
      <mt-field v-model="carid" label="*审批流:">
        <span style="color:#000;display:inline-block;text-align:right" @click="addcarid">{{ chouseval }}</span>
      </mt-field>
    </div>
    <mt-popup v-model="popupVisible22" position="bottom" class="mint-popup" style="width:100%;">
      <mt-picker :slots="dataList" :visible-item-count="5" :show-toolbar="true" value-key="showname" @change="onDateChange">
        <mt-button class="sure" style="display:block;position: absolute;right: 0px;" @click="handleConfirm2">确认</mt-button>
      </mt-picker>
    </mt-popup>
  </div>
</template>
<script>
export default {
  props: {
    atypeid: String,
    num: Number,
    number: Number
  },

  data () {
    return {
      popupVisible22: false,
      chouseval: '',
      returnval: {},
      carid: '',
      ts: this.newStore(),
      dataList: [
        {
          flex: 1,
          values: [],
          className: 'slot1',
          textAlign: 'center'
        }
      ]
    }
  },
  mounted () {
    this.chouseval = '请选择审批流'
    console.log(this.num, '09090')
  },
  methods: {
    addcarid () {
      document
        .getElementsByTagName('body')[0]
        .addEventListener('touchmove', this.handler, { passive: false })
      if (this.num == 0) {
        if (this.atypeid == '0105' || this.atypeid == '0103') {
          this.$messagebox('提示', '请正确输入时间')
        } else {
          this.$messagebox('提示', '请输入金额')
        }

        return
      } else {
        const req = {
          handle:
            '9000B8B8D347526960C5BAB1FB6894EF7C48DC21B3716A54CD3A43E9777C4E90',
          orgid: localStorage.getItem('dept'),
          ftype: this.atypeid,
          number: this.num
        }
        this.spost(this.ts, '/mainservlet', req).then(ts => {
          // console.log(ts.d);
          // this.splList = ts.d.data.operation1
          let a = []
          let item
          for (let index = 0; index < ts.d.data.operation1.length; index += 1) {
            let b = {}
            item = ts.d.data.operation1[index]
            b.id = item.hash.id
            b.showname =
              item.hash.approval_username.replace(/,/g, ' - ') + item.hash.fname
            a.push(b)
          }
          this.dataList[0].values = a
        })
        this.popupVisible22 = true
      }
    },
    onDateChange (picker, values) {
      console.log(picker)
      console.log(values)
      this.returnval = values[0]
      if (values[0]) {
        this.chouseval = values[0].showname
      }
    },
    handleConfirm2 () {
      document
        .getElementsByTagName('body')[0]
        .removeEventListener('touchmove', this.handler, { passive: false })
      //console.log(this.$refs.picker.getValues()[0],'2222');

      //this.chouseval = this.$refs.picker.getValues()[0]
      this.popupVisible22 = false
      this.$emit('getspl', this.returnval)
    }
  }
}
</script>
<style scoped>
</style>
